﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AspNetCs.Bll;
using AspNetCs.Common;
using AspNetCs.Model;
using AspNetCs.Enumerations;
using AspNetCs.Enumerations.Channel_Enum;
public partial class Users_Cemetery_List : BasePage
{
    protected string WhereStr = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        CheckUserExit("Login.Aspx?ReUrl=" + configInfo.InstallDir + "Users/Cemetery_List.Aspx", "请您登录", true);
        WhereStr = " CreateId=" + Base_GetLoginInfo.GetUserID.ToString();
        if (!Page.IsPostBack)
        {
            bind();
        }
    }
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        bind();
    }
    protected void bind()
    {

        this.AspNetPager1.UrlRewritePattern = "Cemetery_List_{0}.Aspx";
        this.AspNetPager1.PageSize = 15;
        Pager p = new Pager();
        p.PageIndex = this.AspNetPager1.CurrentPageIndex;
        p.Ident = "id";
        p.Obj = Repeater1;
        p.Orderfld = "Addtime";
        p.OrderType = "desc";
        p.PageIndex = this.AspNetPager1.CurrentPageIndex;
        p.PageSize = this.AspNetPager1.PageSize;
        p.TableName = "Cemetery";
        p.WhereStr = WhereStr;
        p.ControlBind();
        this.AspNetPager1.RecordCount = p.recordcount();

    }


    protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "delinfo")
        {
            Cemetery_Bll.CreateNew.delete(" id=" + e.CommandArgument.ToString());
            Response.Redirect(AddSuffix("Cemetery_List_" + this.AspNetPager1.CurrentPageIndex + ".Aspx"));
        }
        if (e.CommandName == "CreateHtml")
        {
            Cemetery_Model HTMLmd = Cemetery_Bll.CreateNew.GetModel(StringHelper.isNumber_int(e.CommandArgument.ToString()));
            string NumUrl = HTMLmd.Numid + ".html";

            string CreateHtmlUrl = configInfo.InstallDir + "Html/" + Channel_Type.cemetery.ToString() + "/" + NumUrl;
            TempleBll.CreateNew.TempleCreate(Server.MapPath(CreateHtmlUrl), NumUrl, Channel_Type.cemetery, true);
            Response.Write("<script>alert('生成成功！');location.href='Cemetery_List.aspx';</script>");
            Response.End();
        }
    }
}
